// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);
import { Switch } from 'mint-ui';
import 'bootstrap'
import $ from 'jquery'

Vue.component(Switch.name, Switch);
//安装配置axios插件
var axios = require('axios');//创建axios对象
//设置axios访问代理的基础url
axios.defaults.baseURL = 'http://localhost:8089' ;
//将后端服务器的状态信息(cookie)通过前端服务器并转发到浏览器
axios.defaults.withCredentials=true;
//将axios对象设置为vue的原生对象,别名为http
Vue.prototype.$http = axios ;

Vue.config.productionTip = false
//添加拦截器,在请求头部加token
axios.interceptors.request.use(
  config=>{
    if(localStorage.getItem('token')){
      config.headers.token = localStorage.getItem('token');
    }
    return config;
  },
  error=>{
    return Promise.reject(error);
  }
);
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
